#include "Teacher.h"
#include <string.h>

Teacher::Teacher(){
        age = 33;
        m_pname = new char[1];
        strcpy(m_pname, "");        
}

Teacher::Teacher(char *name, int age){
        this->age = age;
        m_pname = new char[strlen(name)+1];
        strcpy(m_pname, name);
}

Teacher::Teacher(const Teacher &obj){
        m_pname = new char[strlen(obj.m_pname) + 1];
        strcpy(m_pname, obj.m_pname);
        age = obj.age;
}

Teacher& Teacher::operator=(const Teacher &obj){
        if(m_pname != NULL){
                delete [] m_pname;
                m_pname = NULL;
                age = 33;
        }

        m_pname = new char[strlen(obj.m_pname) + 1];
        
        strcpy(m_pname, obj.m_pname);

        age = obj.age;

        return *this;
}


Teacher::~Teacher(){
        if(m_pname != NULL){
                delete [] m_pname;
                m_pname = NULL;
        }
}